package com.yixia.system.mapper.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yixia.system.domain.system.SysRoleDept;
import org.apache.ibatis.annotations.Mapper;


import java.util.ArrayList;
import java.util.List;

/**
* @author 35038
* @description 针对表【sys_role_dept(角色和部门关联表)】的数据库操作Mapper
* @createDate 2023-08-01 17:15:08
* @Entity com.java1234.entity.SysRoleDept
*/
@Mapper
public interface SysRoleDeptMapper extends BaseMapper<SysRoleDept> {

    /**
     * 删除对应的角色部门表信息
     * @param roleIds
     */
    default int deleteRoleDeptByRoleIds(Long[] roleIds){
        LambdaQueryWrapper<SysRoleDept> queryWrapper = new LambdaQueryWrapper<>();
        //queryWrapper.in(SysRoleDept::getRoleId, roleIds);
        int rows = this.delete(queryWrapper);
        return rows;
    }

    /**
     * 通过角色ID删除角色和部门关联
     *
     * @param roleId 角色ID
     * @return 结果
     */
    int deleteRoleDeptByRoleId(Long roleId);

    default int batchRoleDept(List<SysRoleDept> list){
        int i = 0;
        for (SysRoleDept roleDept : list) {
            int insert = this.insert(roleDept);
            i = insert + i;
        }
        return i;
    }
}




